//
//  ActivityCell.m
//  SDSY
//
//  Created by 蓝布鲁 on 2017/3/20.
//  Copyright © 2017年 蓝布鲁. All rights reserved.
//

#import "ActivityCell.h"



@implementation ActivityCell

// 自定义构造函数
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupView];
    }
    return self;
}

- (void)setupView {
    // 活动海报
    self.activityimageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.activityimageView];
    
    // 活动名
    self.nameView = [[ActivityDetailView alloc] init];
    [self.contentView addSubview:self.nameView];
    
    // 活动时间
    self.dateView = [[ActivityDetailView alloc] init];
    [self.contentView addSubview:self.dateView];
    
    // 活动地点
    self.locationView = [[ActivityDetailView alloc] init];
    [self.contentView addSubview:self.locationView];
    
    // 布局设置
    self.activityimageView.sd_layout.leftSpaceToView(self.contentView,0).topSpaceToView(self.contentView,0).widthIs(SCREEN_WIDTH).heightIs(200);
    
    self.nameView.sd_layout.leftSpaceToView(self.contentView,0).topSpaceToView(self.activityimageView,5).widthIs(SCREEN_WIDTH).heightIs(17);
    
    self.dateView.sd_layout.leftSpaceToView(self.contentView,0).topSpaceToView(self.nameView,5).widthIs(SCREEN_WIDTH).heightIs(17);
    
    self.locationView.sd_layout.leftSpaceToView(self.contentView,0).topSpaceToView(self.dateView,5).widthIs(200).heightIs(17);
    
    
}


-(void)setModel:(ActivityModel *)model {
    _model = model;
    
    // 活动海报
    [self.activityimageView sd_setImageWithURL:[NSURL URLWithString:self.model.picture_url] placeholderImage:[UIImage imageNamed:@"Error"]];
    
    // 活动名
    self.nameView.imageName = @"activity_name";
    self.nameView.title = self.model.name;
    [self.nameView setNeedsLayout];
    
    // 活动时间
    self.dateView.imageName = @"activity_date";
    self.dateView.title = self.model.starttime;
    [self.dateView setNeedsLayout];
    
    // 活动地点
    self.locationView.imageName = @"activity_location";
    self.locationView.title = self.model.address;
    [self.locationView setNeedsLayout];
    
    [self setupAutoHeightWithBottomView:self.locationView bottomMargin:5];
}



@end
